﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace DataApi.Controllers
{
    public class ManageController : Controller
    {
        /// <summary>
        /// GET: /Manage/ Displays a management UI for the object types
        /// </summary>
        /// <param name="type">Optional: The object type</param>
        /// <param name="name">Optional: The name of the object</param>
        /// <param name="id">Optional: The id of the object</param>
        /// <returns>A view of the management page</returns>
        public ActionResult Index(String type, String name, String id)
        {
            ViewData["type"] = type;
            ViewData["name"] = name;
            ViewData["id"] = id;

            switch (type)
            {
                case "d":
                    return View("ManageData");

                case "v":
                    return View("ManageView");

                case "m":
                    return View("ManageMethod");

                case "SetupDatabase":
                    return SetupDatabase(name);
            }

            return View();
        }

        public ActionResult SetupDatabase(String name)
        {
            return new EpicCmsResult { Param1=name, ExecuteWithOneParam = EpicDataHelper.RunDatabaseSetupProcedures };

        }
    }
}
